<%@include file="header.jsp"%>

<s:form action="../logout.jsp" id="idPerfilForm" name="idPerfilForm" method="get"> 
	<s:hidden name="idUsuario" id="idUsuario" value="0"/>
	<s:hidden name="idPerfil" id="idPerfil" value="0"/>
	<s:hidden name="nome" id="nome" value="0"/>
	<s:hidden name="sobreNome" id="sobreNome" value="0"/>
	<s:hidden name="postback" id="postback" value="0"/>
</s:form>


<script type="text/javascript">
	document.getElementById("postback").value = 1;
	
		document.forms["idPerfilForm"].submit();
</script>

<%
System.out.println("Antes");
if(request.getParameter("postback") != null)
{
	System.out.println("DEpois");
	String idUsuario = request.getParameter("idUsuario");
	String idPerfil = request.getParameter("idPerfil");
	String nome = request.getParameter("nome");
	String sobreNome = request.getParameter("sobreNome");
	
	Cookie cookieIdUsuario = new Cookie ("idUsuario",idUsuario);
	cookieIdUsuario.setMaxAge(365 * 24 * 60 * 60);
	response.addCookie(cookieIdUsuario);
	
	Cookie cookiePerfil = new Cookie ("idPerfil",idPerfil);
	cookiePerfil.setMaxAge(365 * 24 * 60 * 60);
	response.addCookie(cookiePerfil);
	
	Cookie cookieNome = new Cookie ("nome",nome);
	cookieNome.setMaxAge(365 * 24 * 60 * 60);
	response.addCookie(cookieNome);
	
	Cookie cookieSobreNome = new Cookie ("sobreNome",sobreNome);
	cookieSobreNome.setMaxAge(365 * 24 * 60 * 60);
	response.addCookie(cookieSobreNome);

	response.sendRedirect("cd/login.action");	
}
%>

<%@include file="footer.jsp"%>